package l2ft.gameserver.model.instances;

import l2ft.gameserver.handler.bbs.CommunityBoardManager;
import l2ft.gameserver.model.Player;
import l2ft.gameserver.network.l2.s2c.NpcHtmlMessage;
import l2ft.gameserver.templates.npc.NpcTemplate;

public class FightClubNpcInstance extends NpcInstance
{
	public FightClubNpcInstance(int objectId, NpcTemplate template)
	{
		super(objectId, template);
	}

	@Override
	public void onBypassFeedback(Player player, String command)
	{
		System.out.println("onBypassFeedback");
		switch(command)
		{
		case "quickMatch":
			CommunityBoardManager.getInstance().getCommunityHandler("_fightClubQuickBattle_").onBypassCommand(player, "_fightClubQuickBattle_");
			break;
		case "chooseGame":
			CommunityBoardManager.getInstance().getCommunityHandler("_fightClubChooseGame_").onBypassCommand(player, "_fightClubChooseGame_");
			break;
		case "observe":
			CommunityBoardManager.getInstance().getCommunityHandler("_fightClubObserve_").onBypassCommand(player, "_fightClubObserve_");
			break;
		}
	}

	@Override
	public void showChatWindow(Player player, int val, Object... replace)
	{
		if(player.getFightClubGameRoom() != null)
		{
			 CommunityBoardManager.getInstance().getCommunityHandler("_fightClubGameRoom_").onBypassCommand(player, "_fightClubGameRoom_");
		}
		else
		{
			NpcHtmlMessage packet = new NpcHtmlMessage(player, this);
			packet.setHtml(mainPage(player));
			player.sendPacket(packet);
		}
	}
	
	@Override
	public String getHtmlPath(int npcId, int val, Player player)
	{
		if(val == 0)
			return "custom/" + npcId + ".htm";
		else
			return "custom/" + npcId + "-" + val + ".htm";
	}
	
	private String mainPage(Player player)
	{
		String html = "<html><head><title>Fight Club Manager</title></head><body>";
		html += "<br1>Welcome Soldier!<br>What do you want to do?<br>";
		html += "<table width=290>";
		html += "	<tr>";
		html += "		<td>";
		html += "		<center>";
		html += "<button value = \"Quick Match\" action=\"bypass -h npc_"+getObjectId()+"_quickMatch\" back=\"l2ui_ct1.button.OlympiadWnd_DF_Apply_Down\" width=200 height=30 fore=\"l2ui_ct1.button.OlympiadWnd_DF_Apply\">";
		html += "		</center>";
		html += "		</td>";
		html += "	</tr>";
		html += "	<tr>";
		html += "		<td>";
		html += "		<center>";
		html += "<button value = \"Choose Game\" action=\"bypass -h npc_"+getObjectId()+"_chooseGame\" back=\"l2ui_ct1.button.OlympiadWnd_DF_Fight1None_Down\" width=200 height=30 fore=\"l2ui_ct1.button.OlympiadWnd_DF_Fight1None\">";
		html += "		</center>";
		html += "		</td>";
		html += "	</tr>";
		html += "	<tr>";
		html += "		<td>";
		html += "		<center>";
		html += "<button value = \"Observe\" action=\"bypass -h npc_"+getObjectId()+"_observe\" back=\"l2ui_ct1.button.OlympiadWnd_DF_Watch_Down\" width=200 height=30 fore=\"l2ui_ct1.button.OlympiadWnd_DF_Watch\">";
		html += "		</center>";
		html += "		</td>";
		html += "	</tr>";
		html += "</table>";
		html += "</body></html>";
		
		return html;
	}
}
